package com.gnerv.tools.entity.extend.utils.mapper;

import com.gnerv.tools.entity.extend.annotation.EntityExtend;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ResultMap;
import org.apache.ibatis.session.Configuration;

import java.util.Set;

public class ConfigurationUtils {

    private ConfigurationUtils() {
    }

    public static Configuration buildConfiguration(MappedStatement ms, Set<EntityExtend> entityExtends) {
        Configuration configuration = ms.getConfiguration();
        boolean b = configuration.hasResultMap(ResultMapUtils.buildExtendResultMapId(ms));
        if (!b) {
            ResultMap resultMap = ResultMapUtils.buildExtendResultMap(ms, entityExtends);
            configuration.addResultMap(resultMap);
        }
        return configuration;
    }

}
